//#ifndef QUADTREE_H
//#define QUADTREE_H
#pragma  once
#include "QNode.h"
//#include "CTreeObject.h"
#include "Collision.h"
#include "Object.h"

#include "Utility.h"

//#include <map>
 

class QuadTree
{
private:
	QNode *root;

public:
	int max_level;
	list<Object*> obj_list;

	QNode* getRoot() {return root;}
	void setRoot(QNode * obj) {this->root = obj;}

	QuadTree();
	QuadTree(int pos_x, int pos_y, int size, int level);
	~QuadTree();

	//Object Game
	void clip(RECT camara_rect, QNode *p_qnode, list<Object*>* p_obj_list);

	void getObjFromCamara(RECT camara_rect, list<Object*>* p_obj_list);
	void getObjFromCamara(QNode *p_qnode, RECT camara_rect, list<Object*>* p_obj_list);

	void getObjList(list<Object*>* p_obj_list);
	void getObjList(QNode *p_qnode, list<Object*>* p_obj_list);


	// Background Game
	list<int> tiles_list;
	// build quadtree tiles
	void addAllTiles(char* matrix_file);
	void divide();
	void build(QNode *p_qnode);
	void clipToNode(TilesObject *p_tiles, QNode *p_qnode);

	//get tiles from quadtree
	void clipTiles(RECT camara_rect, QNode *p_qnode, list<TilesObject*>* p_tiles_list);
	void getTilesBgFromCamara(RECT camara_rect, list<TilesObject*>* p_tiles_list);
	void getTilesBgFromCamara(QNode *p_qnode, RECT camara_rect, list<TilesObject*>* p_tiles_list);

	void getTilesList(list<TilesObject*>* p_tiles_list);
	void getTilesList(QNode *p_qnode, list<TilesObject*>* p_tiles_list);	
};


//#endif